package test;

public class OperatorTest2 {
	public static void main(String[] args) {
		System.out.println(0b00000000000000000000000000000001);
		System.out.println(0b11111111111111111111111111111111);
		System.out.println(0b11111111111111111111111111111110);
		System.out.println(0b11111111111111111111111111111101);
		System.out.println(0b01111111111111111111111111111111);
		System.out.println(0b10000000000000000000000000000000);
		System.out.println(0b10000000000000000000000000000001);
		System.out.println(Integer.toBinaryString(Integer.MIN_VALUE));
		System.out.println();
		// 负数以原码的补码形式表达 负数补码=源码除符号位取反+1 负数反码=源码除符号位取反
		System.out.println(Integer.toBinaryString(-1)); // 11111111111111111111111111111111
		System.out.println(Integer.toBinaryString(-2)); // 11111111111111111111111111111110
		System.out.println(Integer.toBinaryString(-3)); //11111111111111111111111111111101
		// >>：带符号右移。正数右移高位补0，负数右移高位补1。
		System.out.println(Integer.toBinaryString(-3 >> 1));//11111111111111111111111111111110
		System.out.println(Integer.toBinaryString(-4 >> 1));//11111111111111111111111111111110
		System.out.println(-3 >> 1);
		// >>>：无符号右移。无论是正数还是负数，高位通通补0。
		System.out.println(Integer.toBinaryString(-3 >>> 1));//01111111111111111111111111111110
		System.out.println(-3 >>> 1);
		System.out.println(Integer.MIN_VALUE >>> 1); // 1073741824


		System.out.println(Integer.MAX_VALUE + 1); // -2147483648
		System.out.println(Integer.MAX_VALUE + 2); // -2147483647

	}
}
